<%@page contentType="text/html;charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用户列表</title>
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/sweetalert2.js"></script>
<link rel="stylesheet" type="text/css" href="css/list.css">
<script type="text/javascript">
	function showPreview(previewObj){
		var preview = $(previewObj).attr("data-preview");
		var pname = $(previewObj).attr("usersList.user_name");
		Swal.fire({
			title:pname,
			html:"<img src='"+preview+"' style='width:361px;height:240px'>",
			showCloseButton:true,
			showConfirmButton:false
		});
	}
	
	function del(delObj){
		var pname = $(delObj).attr("usersList.user_name");
		var id = $(delObj).attr("usersList.user_id");
		var preview = $(delObj).attr("data-preview");
		Swal.fire({
			title:"确认要删除["+pname+"]油画吗？",
			html:"<img src='"+preview+"' style='width:361px;height:240px'>",
			showCancelButton:true,
			confirmButtonText:"是",
			cancelButtonText:"否"
		}).then(function(result){
			if(result.value == true){
				//alert("你点了'是'按钮");
				$.ajax({
					url:"management?method=delete&id="+id,
					type:"get",
					dataType:"json",
					success:function(json){
						if(json.result=="ok"){
							window.location.reload();
						}else{
							Swal.fire({
								title:json.result
							})
						}
					}
				})
			}	
		})
		
	}
</script>
</head>
<body>
	<div class="container">
		<fieldset>
			<legend>用户管理</legend>
			<!-- 用户列表 -->
			<table cellspacing="0px">
				<thead>
					<tr style="width: 120px;">
						<th style="width: 100px">昵称</th>
						<th style="width: 100px;">性别</th>
						<th style="width: 100px;">余额</th>
						<th style="width: 250px">联系方式</th>
						<th style="width: 250px">地址</th>
						<th style="width: 250px">操作</th>
					</tr>
				</thead>
				<c:forEach items="${usersList }" var="usersList" >
					<tr>
						<c:choose>
							<c:when test="${painting.category==1 }"><td>现实主义</td></c:when>
							<c:when test="${painting.category==2 }"><td>抽象主义</td></c:when>
						</c:choose>
						<td>${usersList.user_name }</td>
						<td>${usersList.user_sex }</td>
						<td>${usersList.user_salary }</td>
						<td>${usersList.user_tel }</td>
						<td>${usersList.user_addr }</td>
						<td>
							<a class="oplink" href="management?method=ushow_update&user_id=${usersList.user_id}">修改</a>
                            <a class="oplink" href="management?method=udelete&user_id=${usersList.user_id}">删除</a>
						</td>
					</tr>
				</c:forEach>
			</table>
			<!-- 分页组件 -->
			<ul class="page">
				<li><a href="management?method=list&p=1">首页</a></li>
				<li><a href="management?method=list&p=${pageModel.hasPreviousPage?pageModel.page-1:1 }">上页</a></li>
				<c:forEach begin="1" end="${pageModel.totalPages }" var="pno" step="1">
				<li ${pno==pageModel.page?"class='active'":"" }>
					<a href="management?method=list&p=${pno }">${pno }</a>
				</li>
				</c:forEach>
				<li><a href="management?method=list&p=${pageModel.hasNextPage?pageModel.page+1:pageModel.totalPages }">下页</a></li>
				<li><a href="management?method=list&p=${pageModel.totalPages }">尾页</a></li>
			</ul>
		</fieldset>
	</div>

</body>
</html>
